﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.Linq;
using ChatData;

namespace ChatServerOptions
{
    /// <summary>
    /// Stores files on the Client Side
    /// </summary>
    public class FileStore : TimeStream<FilePost>
    {
        public FileStore()
        {
        }
        public FileStore(FilePost thepost)
        {
            this.Add(thepost);
        }
        public FilePost getByGUID(String GUID)
        {
            var theitem = from FilePost item in this
                          where item.GUID == GUID
                          select item;
            FilePost[] temp = theitem.ToArray<FilePost>();
            return temp[0];
        }
        public string pathByGUID(String GUID)
        {
            var theitem = from FilePost item in this
                          where item.GUID == GUID
                          select item.LocalFile;
            List<string> thelist = theitem.ToList<String>();
            return thelist[0];
        }
        public FilePost getByUser(String user)
        {
            var theitem = from FilePost item in this
                          where item.User == user
                          select item;
            return (FilePost)theitem;
        }
    }
}
